<template>
  <div>
    <div class="head-top">
      <mt-header title="报纸详情列表">
        <mt-button icon="back" slot="left" @click='back'></mt-button>
      </mt-header>
    </div>

    <div class="main">
      <div class="cell">
        <div v-for="(item,index) in perlist" :key="index" @click="goToContent(item)">
          <p class="time"><img src="../../../../static/yuan.png" alt="">{{item.external_source_name}}</p>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import api from "./../../../api/api.js";
import baseurl from "../../../api/baseurl.js"
import { Indicator } from "mint-ui";

export default {
  data() {
    return {
      parperid: "",
      perlist: []
    };
  },
  created() {
    this.parperid = JSON.parse(this.$route.params.parperid);
    this.fileid = this.$route.params.parper_name
    this.getinfoList();
  },
  methods: {
    // 行为记录
    readRecord(e) {
      const userid = localStorage.getItem("userid");
      const accid = localStorage.getItem("accid");
      const params = new URLSearchParams();
      params.append("title", e.external_source_name);
      params.append("type", 4);
      params.append("userid", userid);
      params.append("fileid", this.fileid);
      params.append("recorddate", "");
      params.append("describ", e.file_name);
      params.append("imgurl", "");
      params.append("author","");
      params.append("edition", accid);
      this.$http({
        method: "post",
        url: baseurl.urls + "readrecord/addReadrecord",
        data: params
      })
        .then(response => {
          console.log(response);
        })
        .catch(error => {
          console.log(error);
        });
    },
    goToContent(e){
      this.readRecord(e);
      let imgSrc = api.PdfSrc
      let str = e.file_name.substring(0, 12);
      this.$router.push({
        name: "readingPdf",
        params: {
		    bookurl: imgSrc+"/skjc_bz/"+str+"/"+e.file_name+".pdf",
		    bookName:e.external_source_name
        }
      });
    },
    back() {
      this.$router.back(-1);
    },

    getinfoList() {
      this.$http({
        method: "post",
        url: api.baseURL + "getCnkiDetailInformation",
        params: {
          inParam: {
            constraint: [
              {
                name: "date",
                value: this.parperid
              }
            ],
            time: this.datevalue,
            userId: 506,
            pageSize: 10,
            queryfield: ["file_name", "external_source_name"],
            currentPage: 1,
            resourceType: 4,
            sysCode: "FH_PUBOPE"
          }
        }
      })
        .then(response => {
          if (response.status == 200) {
            this.perlist = response.data.data;
            console.log(response);
          }
        })
        .catch(error => {
          console.log(error);
        });
    }
  }
};
</script>

<style>
.main .cell {
  margin-top: 16px;
  margin-bottom: 65px;
}

.main .time {
  width: 100%;
  height: 45px;
  background: #fff;
  margin-top: 2px;
  line-height: 45px;
  padding: 0 10px;
  box-sizing: border-box;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.time>img{
  margin-right: 10px;
}
</style>